﻿#region Header Licence
//  NKnobMan, Copyright 2009, Alexandre MUTEL.
// 
//  This is free software; you can redistribute it and/or modify it
//  under the terms of the GNU Lesser General Public License as
//  published by the Free Software Foundation; either version 2.1 of
//  the License, or (at your option) any later version.
// 
//  This software is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//  Lesser General Public License for more details.
// 
//  You should have received a copy of the GNU Lesser General Public
//  License along with this software; if not, write to the Free
//  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
//  02110-1301 USA, or see the FSF site: http://www.fsf.org.
#endregion
using System.ComponentModel;
using System.Windows.Forms;

namespace NKnobMan
{
    /// <summary>
    /// KnobManFormBase base
    /// </summary>
    public partial class KnobManFormBase : Form
    {
        private KnobMan _knobMan;

        public KnobManFormBase()
        {
            InitializeComponent();

            // DesignMode hack (DesignMode is not working in Form & UserForm constructors)
            // See: http://dotnetfacts.blogspot.com/2009/01/identifying-run-time-and-design-mode.html
            if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
            {
                KnobMan = KnobMan.Default;
                if (KnobMan == null)
                {
                    Close();
                }
                else
                {
                    Icon = KnobMan.Icon;
                }
            }
        }

        public KnobMan KnobMan
        {
            get { return _knobMan; }
            set
            {
                if ( _knobMan != value )
                {
                    _knobMan = value;
                }
            }
        }        

        public void ShowDialogFromKnobMan()
        {
            ShowDialog(KnobMan);
        }

    }
}
